package com.gbei.center.oauth.mapper;

import com.gbei.center.oauth.model.PlatformUser;
import com.gbei.center.oauth.model.vo.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

/**
 * @Description: TODO
 * @author xiechengguang
 * @date 2019年2月15日
 */
public interface PlatformUserMapper extends Mapper<PlatformUser> {
	/**
	 * @Description: 通过用户名和密码查询用户
	 * @param name
	 * @param password
	 * @return User  
	 * @throws
	 */
	@Select("select * from t_user where `status`=1 AND password = #{password} AND (account = #{name} OR idcard = #{name} OR mobile = #{name})")
    PlatformUser selectUserByNameAndPassword(@Param("name") String name, @Param("password") String password);

	/**
	 * 根据用户ID查找记录(返回到客户端)
	 * @param userId
	 * @return
	 */
	@Select("select user_id as id, nick_name,name,account,mobile,head_file,address,email from t_user where `status`=1 AND user_id = #{userId}")
	UserInfo userInfoByUserId(@Param("userId") String userId);


	/**
	 * 根据用户ID查找记录
	 * @param userId
	 * @return
	 */
	@Select("select * from t_user where `status`=1 AND user_id = #{userId}")
	PlatformUser selectByUserId(@Param("userId") String userId);
	
}
